package pattern14;

/**
 * 发起者类
 *
 * @author wdl
 */
public class Originator {
    private String state;

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    /**
     * 创建一个备份
     *
     * @return 返回备份
     */
    public Memento createMemento() {
        return new Memento(state);
    }

    /**
     * 恢复备份
     * @param memento 备份数据对象
     */
    public void getStateFromMemento(Memento memento) {
        state = memento.getState();
    }

    public void show(){
        System.out.println(state);
    }
}
